/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cx1.dao.impl;

import com.ibatis.sqlmap.client.SqlMapClient;
import java.util.ArrayList;
import java.util.List;
import org.cx1.dao.api.IFeaturedDao;
import org.cx1.model.Featured;

/**
 *
 * @author ECH
 */
public class FeaturedDao implements IFeaturedDao {

    private SqlMapClient sqlMapClient;

    public FeaturedDao() {
        sqlMapClient = IbatisConnectionFactory.getSqlMapClient();
    }
    
    @Override
    public List<Featured> getAll() {
        List<Featured> amenities = new ArrayList<Featured>();        
        try {
            amenities = sqlMapClient.queryForList("featured.getAll");
        } 
        catch (Exception ex) {
            ex.printStackTrace();
        }        
        return amenities;
    }

    @Override
    public Featured getById(String id) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public String add(Featured featured) {
        String featuredId = "";        
        try {
            sqlMapClient.insert("featured.add", featured);
            featuredId = featured.getId();            
        } 
        catch (Exception ex) {
            ex.printStackTrace();
        }        
        return featuredId;
    }

    @Override
    public int update(Featured featured) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public int deleteById(String id) {
        int noOfRowsAffected = 0;        
        try {
            noOfRowsAffected = sqlMapClient.delete("featured.deleteById", id);
        } catch (Exception ex) {
            ex.printStackTrace();
        }        
        return noOfRowsAffected;
    }
    
}
